package model;

import Service.Impl.DistinguishServiceImpl;
import Service.Impl.MyChangeServiceImpl;
import Service.Impl.SystemRealServiceImpl;

import java.util.Collections;

public class forTest {
    public static void main(String[] args) {
        int n = 15;
        char ch = 'c';
        System.out.println(java.lang.Integer.toHexString(ch & 0XFF));
        Integer temp = n;
        String c = "adc";
        System.out.println(System.identityHashCode(n));
        System.out.println(System.identityHashCode(temp));
        System.out.println(System.identityHashCode(c));
        System.out.println(Integer.toHexString(n));
        System.out.println("================================");
        SystemRealServiceImpl locationService = new SystemRealServiceImpl();
        System.out.println(locationService.realLocation(n));
        Object tempObj = ch;
        if (tempObj instanceof Integer) {
            System.out.println("Integer");
        } else if (tempObj instanceof Character) {
            System.out.println("Character");
        } else if (tempObj instanceof Float) {
            System.out.println("Float");
        } else {
            System.out.println("Wrong");
        }

        DistinguishServiceImpl distinguishService = new DistinguishServiceImpl();
        System.out.println(distinguishService.distinguish(n));
        System.out.println("================================");

        MyChangeServiceImpl myChangeService = new MyChangeServiceImpl();
        int a = (int)'a';
        String stringDecimal = myChangeService.intToBinary(a);
        System.out.println(stringDecimal);
        byte the0 = (byte) stringDecimal.charAt(0);
        System.out.println("the0: "+ the0);
        byte[] decimalByte = new byte[stringDecimal.length()];
        char decimalCh[] = new char[stringDecimal.length()];
        System.out.println("---decimalCh---");
        for (int i=0 ; i<stringDecimal.length() ; i++) {
            decimalCh[i] = stringDecimal.charAt(i);
            if (decimalCh[i] == '1') {
                decimalByte[i] = 1;
            } else if (decimalCh[i] == '0') {
                decimalByte[i] = 0;
            }
        }
        for (char b : decimalCh) {
            System.out.print(b);
        }
        System.out.println("");
        System.out.println("---decimalByte---");
        for (byte b : decimalByte) {
            System.out.print(b);
        }
        System.out.println("---decimalByte转16进制---");
        System.out.println(myChangeService.parseByte2HexStr(decimalByte));
        System.out.println("");
        System.out.println("================================");
        System.out.println((4>>1)&1);
        System.out.println(myChangeService.changeToByte(myChangeService.FloatToBinary(1.11F)));
        System.out.println(myChangeService.intToBinary((int)a));

        System.out.println("--------------------------------");
        System.out.println(1%4);
        forTestAgain testAgin = new forTestAgain();
        testAgin.changeTwo(myChangeService.changeToByte(myChangeService.intToBinary(-3)));

        String tempString = String.join(String.join("10101", Collections.nCopies(4, "0")));
        System.out.println("tempString"+ tempString);
    }
}
